home *** CD-ROM | disk | FTP | other *** search
- Path: rcp6.elan.af.mil!rscernix!danpop
- From: danpop@mail.cern.ch (Dan Pop)
- Newsgroups: comp.lang.c
- Subject: Re: realloc(NULL,100)
- Date: 28 Feb 96 16:34:11 GMT
- Organization: CERN European Lab for Particle Physics
- Message-ID: <danpop.825525251@rscernix>
- References: <31346CB0.41C67EA6@jupiter.di.uminho.pt>
- NNTP-Posting-Host: ues5.cern.ch
- X-Newsreader: NN version 6.5.0 #7 (NOV)
-
- In <31346CB0.41C67EA6@jupiter.di.uminho.pt> Rui Bastos <rui@jupiter.di.uminho.pt> writes:
-
- > Does anybody knows what's the expected behaviour of this program?
-
- Undefined, because you include the nonstandard header <malloc.h> and
- use realloc without including <stdlib.h> (or declaring it yoursef).
-
- >#include <stdio.h>
- >#include <malloc.h>
-
- s/malloc/stdlib
-
- >main()
- >{
- > void *x=NULL;
- > x=realloc(NULL,100);
- > printf("%p\n",x);
- >}
- >
- > I tested it under diferent compilers/operating systems
- >and it returns null, others returns a valid address and other
- >crashes.
-
- On systems with pre-ANSI libraries, a crash was the usual behaviour.
- On systems with ANSI libraries, both zero and nonzero results are legal.
- Zero means that realloc couldn't allocate a 100-byte memory block for you.
-
- >PS please and send me an email if you reply to this post.
-
- Because you're too f***ing lazy to look for answers in the newsgroup?
- Or is it because your time is precious, while ours is worth peanuts?
-
- Dan
- --
- Dan Pop
- CERN, CN Division
- Email: danpop@mail.cern.ch
- Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
-